<div align="center">
  <DIV class=boxright>
    <DIV class=bltop2>
      <div align="left">
        <strong>
          &nbsp;&nbsp;&nbsp;当前位置：&nbsp;&nbsp;
          <%=link_to "后台管理", :controller=>"manage",:action=>"index"%>&nbsp;&nbsp;
          <img src="/images/zd_arrow.gif">&nbsp;&nbsp;
          <%=link_to "用户管理", :action=>"show_users"%>
        </strong>
      </div>
    </DIV>
    <DIV class=c_box>
      <DIV class="rep_left">
        <div class="bltop2"><span onclick="hideOrShowDiv('user_div')" class="s_left">添加用户</span></div>
        <div id="user_div">
          <%form_remote_tag  :url => '/permission/add_user' do%>
            <TABLE id=tblSearch  cellSpacing=0 cellPadding=4 width="100%" border=0>
              <TBODY>
                <TR>
                  <TD class=rep_li_c2 width="20%" ALIGN="left">登录名</TD>
                  <TD class=rep_li_c2 width="30%" ALIGN="left">
                    <%= text_field "user","login_name",:class=>"text", :style=>"WIDTH: 130px"%>
                  </TD>
                  <TD class=rep_li_c2 width="20%" ALIGN="left">真实姓名</TD>
                  <TD class=rep_li_c2 width="30%" ALIGN="left">
                    <%= text_field "user","true_name",:class=>"text", :style=>"WIDTH: 130px"%>
                  </TD>
                </TR>
                <TR>
                  <TD class=rep_li_c2 ALIGN="left">单位</TD>
                  <TD class=rep_li_c2 ALIGN="left">
                    <%= text_field "user","depart",:class=>"text", :style=>"WIDTH: 130px"%>
                  </TD>
                  <TD class=rep_li_c2 ALIGN="left">电话</TD>
                  <TD class=rep_li_c2 ALIGN="left">
                    <%= text_field "user","telephone",:class=>"text", :style=>"WIDTH: 130px"%>
                  </TD>
                </TR>
                <TR>
                  <TD class=rep_li_c2 ALIGN="left">选择角色</TD>
                  <TD class=rep_li_c2 ALIGN="left">
                    <%=@roles=Role.find :all
                    collection_select(:role,"id",@roles,:id,:role_name,{},:style=>"WIDTH: 133px")
                  %>
                  </TD>
                  <TD class=rep_li_c2>&nbsp;</TD>
                  <TD class=rep_li_c2 ALIGN="left">&nbsp;</TD>
                </TR>
                <TR>
                  <TD class=rep_li_c2 colSpan=4>
                    <INPUT ONCLICK="return onadd();"
                           onMouseOver="this.className='submit2'"
                           onMouseOut ="this.className='submit'"
                           class=submit
                           id="modify"
                           type=submit
                           value=添加 name="">
                    <INPUT onMouseOver="this.className='reset2'"
                           onMouseOut="this.className='reset'"
                           id="btn8"
                           class="reset"
                           type="reset"
                           value=取消>
                  </TD>
                </TR>
              </TBODY>
            </TABLE>
          <%end%>
        </div>
        <%= observe_field("user[login_name]",:frequency => 1,:update => :ulogin_name,:url => {:controller=>"permission",:action => :check_login_name},:with=>"login_name") %>
        <%form_tag :action => "operator_users" do %>
          <TABLE class=tatop7px cellSpacing=0 cellPadding=4 width="100%" border=0>
            <TBODY>
              <TR>
                <TD class=rtdw width="4%">
                  <INPUT id="chkAll" onclick="title_check('chkAll','chkID[]')"  type=checkbox value=checkbox>
                </TD>
                <TD class=rep_li_c width="18%"><STRONG>登录名</STRONG></TD>
                <TD class=rep_li_c width="18%"><STRONG>真实姓名</STRONG></TD>
                <TD class=rep_li_c width="10%"><STRONG>部门</STRONG></TD>
                <TD class=rep_li_c width="13%"><STRONG>电话</STRONG></TD>
                <TD class=rep_li_c width="10%"><STRONG>状态</STRONG></TD>
                <TD class=rep_li_c width="20%"><STRONG>隶属角色</STRONG></TD>
              </TR>
              <tr id="after_tr"></tr>
              <%for user in @users%>
                <TR id="tr_<%=user.id%>" style="TEXT-DECORATION: none" onMouseOver="this.style.backgroundColor='#EFF8FF'" onmouseout="this.style.backgroundColor=''">
                  <TD class=rtdw2>
                  <INPUT onclick="rows_check('chkAll','chkID[]')" type=checkbox value="<%=user.id%>" name="chkID[]"></TD>
                  <TD class=rep_li_td_bt >
                    &nbsp;<%=user.login_name%>
                  </TD>
                  <TD class=rep_li_td_bt>&nbsp;<%=user.true_name%></TD>
                  <TD class=rep_li_td_bt>&nbsp;<%=user.depart%></TD>
                  <TD class=rep_li_td_bt>&nbsp;<%=user.telephone%></TD>
                  <TD class=rep_li_td_bt>&nbsp;
                    <%=if user.state==1
                      "启用"
                    else
                      "禁用"
                    end
                  %>
                  </TD>
                  <TD class=rep_li_td_bt>&nbsp;
                    <%=user.roles.first.role_name%>
                  </TD>
                </TR>
              <%end%>
            </TBODY>
          </TABLE>

          <TABLE class=tatop7px cellSpacing=0 cellPadding=4 width="100%" border=0>
            <TBODY>
              <TR>
                <TD  align="center">
                  <%=will_paginate @users%>
                </TD>
              </TR>
            </TBODY>
          </TABLE>

          <TABLE id="move_tbl"  style="DISPLAY: none"  cellSpacing=0 cellPadding=4 width="100%" border=0>
            <TBODY>
              <TR>
                <TD class=rtdp height=22 ALIGN="left"><STRONG>选择要更改的角色</STRONG></TD>
                <TD class=rtdp align="right" COLSPAN="3">
                  <LABEL style="CURSOR: pointer" onclick="hideMoving()">关闭</LABEL>
                </TD>
              </TR>
              <TR>
                <TD class=rep_li_c2 width="18%" ALIGN="center">&nbsp;</TD>
                <TD class=rep_li_c2 width="32%">
                  角色名称
                </TD>
                <TD class=rep_li_c2 width="18%" ALIGN="center">
                  <%=@roles=Role.find :all
                  collection_select(:role,"id",@roles,:id,:role_name)
                %>
                </TD>
                <TD class=rep_li_c2 width="32%" ALIGN="left">
                  &nbsp;
                </TD>
              </TR>
              <TR>
                <TD class=rep_li_c2 colSpan=4>
                  <INPUT onMouseOver="this.className='submit2'"
                         onMouseOut ="this.className='submit'"
                         class="submit"
                         type="submit"
                         value="更改"
                         name="button">
                  <INPUT onMouseOver="this.className='reset2'"
                         onMouseOut="this.className='reset'"
                         id="reset"
                         class="reset"
                         type="button" value=取消>
                </TD>
              </TR>
            </TBODY>
          </TABLE>


          <TABLE cellSpacing=0 cellPadding=4 width="100%" border=0>
            <TBODY>
              <TR vAlign="top" ALIGN="left">
                <TD>
                  <INPUT onclick="check_select_one('chkAll','chkID[]')"
                         onMouseOver="this.className='bt1h'"  onMouseOut ="this.className='bt1'"
                         class="bt1" name="button" type="submit" value="启用" id="use">
                  <INPUT onclick="check_select_one('chkAll','chkID[]')"
                         onMouseOver="this.className='bt1h'"  onMouseOut ="this.className='bt1'"
                         class="bt1" name="button" type="submit" value="禁用" id="unuse">
                  <INPUT onclick="check_select_one('chkAll','chkID[]')"
                         onMouseOver="this.className='bt1h'"  onMouseOut ="this.className='bt1'"
                         class="bt1" name="button" type="submit" value="修改" id="user_modify" >
                  <INPUT onclick="check_select_one('chkAll','chkID[]')"
                         onMouseOver="this.className='topanniu2'"  onMouseOut ="this.className='topanniu'"
                         class="button" name="button" type="button" value="密码重置" id="setpass">
                  <INPUT onclick="showMoving('chkAll','chkID[]')"
                         onMouseOver="this.className='topanniu2'"  onMouseOut ="this.className='topanniu'"
                         class="button" name="button"   type="button" value="更改权限" id="setRole">
                </TD>
              </TR>
            </TBODY>
          </TABLE>
        <% end %>
      </DIV>
    </DIV>
    <SCRIPT type="text/javascript">
    function onadd()
    {
      if($("user[login_name]").value.blank()){
        alert("请输入登录名！");
        return false;
      }
      if($("user[true_name]").value.blank())
      {
        alert("请输入真实姓名！");
        return false;
      }
      if($("user[depart]").value.blank())
      {
        alert("请输入单位！");
        return false;
      }
      return true;
    }

    function clearForm()
    {
      $("btn8").click();
    }

    function showMoving(title_id, cbs_name){

      if(check_select_one(title_id, cbs_name)){
        $("move_tbl").style.display="";
      }

    }

    function hideMoving(){
      $("move_tbl").style.display="none";
    }

    function hidetblSearch(){
      $("tblSearch").style.display="none";
      $("tblModify").style.display="";
    }
    </SCRIPT>
  </DIV>
</div>

